package server;

/**
 *@author Adam,Aqeel
 */

import java.rmi.RMISecurityManager;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.Vector;
import hifiSpeakers.RMIServer;

public class RMIHifiClient {
	String name;
	RMIServer server;
	Registry registry;

	public RMIHifiClient(String myName){
		name = myName;
	}

	public void begin(String location) {
		System.setSecurityManager(new RMISecurityManager());
		try {
			registry = LocateRegistry.getRegistry(location);
			System.out.println("looking for RMIServer " + name);
			server = (RMIServer)registry.lookup(name);
			System.out.println("found rmiServer" + name);

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public void streamFrom(String url){
		try{
		server.streamFrom(url);
		} catch (Exception e){
			e.printStackTrace();
		}
	}
	
	public void pauseStream(){
		try{
			server.pauseStream();
			} catch (Exception e){
				e.printStackTrace();
			}
	}
	
	public void playStream(){
		try{
			server.playStream();
			} catch (Exception e){
				e.printStackTrace();
			}
	}
	public void stopStream(){
		try{
			server.stopStream();
			} catch (Exception e){
				e.printStackTrace();
			}
	}
	

	
}
